#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 10;
int n;
int q[N], ans[N];

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> q[i];
	}
	for (int i = 0, last = -n; i < n; ++i) {
		if (q[i] == 0) {
			last = i;
		}
		ans[i] = i - last;
	}
	for (int i = n - 1, last = 2 * n; i >= 0; --i) {
		if (q[i] == 0) {
			last = i;
		}
		ans[i] = min(ans[i], last - i);
	}
	for (int i = 0; i < n; ++i) {
		cout << ans[i] << ' ';
	}
	return 0;
}